<%@page import = "java.sql.*, java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
    <head>
        <title>AdminPage</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="includes/ice/ice.js" type="text/javascript"></script>
    
   <script> 
   var   curRow;       
   var   curRowId;     
   var   curColor;  
   function   selectRow(tr1){  
   if(curRow)  
   {  
     curRow.bgColor=curColor;  
     curColor=tr1.bgColor;  
     tr1.bgColor="#FFE9B3";  
  }else{  
      curColor=tr1.bgColor;  
      tr1.bgColor="#FFE9B3";  
  }  
     curRow=tr1;  
     curRowId=tr1.id;  
  }  
  
  
 
  </script> 
    </head>
    <body>
      
        <form  name = "formAD" action =" " method="post">
        
    <%
     Enumeration user_name = request.getParameterNames();
     while (user_name.hasMoreElements()) {
      String name = (String) user_name.nextElement();
      StringBuffer sb = new StringBuffer(name);
      sb.deleteCharAt(0);
     }

%>
    
    <div>
    <h1><img src="ISMI.jpg" width="245" height="79" alt="Logo" longdesc="ISMI   .jpg"><img src="ismi_design_cube.jpg" width="792" height="120" alt="ISMI_is"></h1>
    </div>
     
     <div id="bc" class="bc"><a href="home.jsp">Home</a> &gt; <strong>Admin</strong></div>
     
     <div id="bodyContent">
     <div class="leftClass" id="LeftNav">
     <!--    
     <table width="150" border="0" align="left">
     <tr>
        <th width="292" scope="row"><input type = "button" value = "View Accounts" onClick="ViewAccounts()">
        </th>
     </tr>
     
     <tr>
        <th width="292" scope="row"><input type = "button" value = "Message" onClick="ViewMessage()"></th>
     </tr>
     
     <tr>
        <th scope="row">&nbsp;</th>
     </tr>
    </table>
    -->
    
    <table width="787" border="0" align="center">
    
        <tr>
        <th colspan="6">User account information</th>
        <tr>
          <th width="103">Last name</th>
          <th width="113">First name</th>
          <th width="189">Email</th>
          <th width="91">Address</th>
          <th width="122">Phone No.</th>
          <th width="70">Appr Statu</th>
        </tr>
        </tr>
        
        <%
         String url = "jdbc:mysql://localhost:3306/ismi";
         Connection con;
         ResultSet rs;
         String s;
         String sqlstr = "SELECT name, lastname, email, Address, telephone, user_name, approved FROM user;";
         String sqlstrdeleteuser = "DELETE from user where user_name = ";
         
         //System.out.println("we");
               try 
               {
                       Class.forName("com.mysql.jdbc.Driver");
               } 
               catch(java.lang.ClassNotFoundException e) 
               {
                       System.err.print("ClassNotFoundException: ");
                       System.err.println(e.getMessage());
               }

               try  
               {
                       con = DriverManager.getConnection(url,"root", "isaac16");
                       System.out.println("test");
                       Statement st = con.createStatement();
                       //Statement stDelete = con.createStatement();
                       rs = st.executeQuery(sqlstr);
                       
                          
                       while(rs.next()){%>
                      
                       <tr>
                       <td onclick="selectRow(this)">
                           
                           <input width="103" name= "Last name" value="<%out.println(rs.getString(1));%>" type="text" readonly>
                           <th><input name= "First name" type="text" readonly width="113" value="<%out.println(rs.getString(2));%>"></th>
                           <th><input name= "Affiliation" type="text" id="Affiliation" readonly width="189" value="<%out.println(rs.getString(3));%>"></th>
                           <th><input name= "E-mail" type="text" readonly  width="91" value="<%out.println(rs.getString(4));%>"></th>
                          <th> <input name= "Phone" type="text" id="Phone" readonly width="" value="<%out.println(rs.getString(5));%>"></th>
                          <th> <input name= "Appro Statu" type="text" id="Appro Statu" readonly width="" value="<%out.println(rs.getString(7));%>"></th>  
                          <th><input name = "c1" type = "checkbox" value="<%out.println(rs.getString(6));%>" ></th></td>
                          <td>&nbsp;</td>
                          
                            
                        
                        </tr>
                        <%}%> 
                        
                        
                         <td><th><th></th></th><th></th><th align="right"><input name= "Approve" type = "submit" value="Approve" align= "right" onclick ="document.formAD.action ='Approve.jsp'"></th>
                          <th align="right"><input name= "Delete" type = "submit" value="Delete" align= "right" onclick ="document.formAD.action='Admin1.jsp'"></th>
                        </table>
                        
                       
                       <%
                       rs.close();
                       st.close();
                       con.close();

               } 
               catch(SQLException ex) 
               {
                       System.err.println("SQLException: " + ex.getMessage());
               }

               
           %>
                     
     </div> 
     </div>^
        </form>
        
     <%System.out.println("we1");%>
    </body>
    
</html>